home *** CD-ROM | disk | FTP | other *** search
- Subject: v23i079: Xmodem file transfer program, revision3.9, Part03/03
- Newsgroups: comp.sources.unix
- Approved: rsalz@uunet.UU.NET
- X-Checksum-Snefru: 575aa8c4 3acd406b 3e11e97b e8f114c2
-
- Submitted-by: Steve Grandi <grandi@noao.edu>
- Posting-number: Volume 23, Issue 79
- Archive-name: xmodem3.9/part03
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: batch.c misc.c xmodem.1 xmodem.h
- # Wrapped by rsalz@litchi.bbn.com on Wed Dec 5 12:31:58 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 3 (of 3)."'
- if test -f 'batch.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'batch.c'\"
- else
- echo shar: Extracting \"'batch.c'\" \(4901 characters\)
- sed "s/^X//" >'batch.c' <<'END_OF_FILE'
- X/*
- X * Various routines for batch transfer
- X */
- X
- X#include "xmodem.h"
- X
- X/* make sure filename sent or received in YMODEM batch is canonical. */
- X
- X/* Incoming: Turn Unix '/' into CP/M ':' and translate to all lower case.
- X * Remove trailing dot.
- X */
- X
- Xunixify (name)
- Xchar *name;
- X {
- X char *ptr;
- X
- X /* change '/' to ':' and convert to lower case */
- X for (ptr=name; *ptr; ++ptr)
- X {
- X if (*ptr == '/')
- X *ptr = ':';
- X if (isupper (*ptr))
- X *ptr |= 040;
- X }
- X
- X /* remove trailing dot if present */
- X ptr--;
- X if (*ptr == '.')
- X *ptr = '\0';
- X }
- X
- X/* make sure filename sent or received in YMODEM batch is canonical. */
- X
- X/* Outgoing: Turn ':' into '/' (for symmetry!) and turn into all lower case.
- X * Remove everything before last '/'. Use "filename" to hold final name.
- X */
- X
- Xchar *
- Xcpmify (name)
- Xchar *name;
- X {
- X char *ptr, *slash;
- X char *strcpy();
- X
- X /* find last '/' and copy rest of name */
- X
- X slash = name;
- X for (ptr=name; *ptr; ++ptr)
- X if (*ptr == '/')
- X slash = ptr + 1;
- X strcpy (filename, slash);
- X
- X /* change ':' to '/' and covert to all lower case */
- X
- X for (ptr=filename; *ptr; ++ptr)
- X {
- X if (*ptr == ':')
- X *ptr = '/';
- X if (isupper (*ptr))
- X *ptr |= 040;
- X }
- X return (filename);
- X }
- X
- X
- X/* convert a CP/M file name received in a MODEM7 batch transfer
- X * into a unix file name mapping '/' into ':', converting to all
- X * upper case and adding dot in proper place.
- X * Use "filename" to hold name.
- X * Code stolen from D. Thompson's (IRTF) xmodem.c
- X */
- X
- Xchar *
- Xcpm_unix (string)
- Xunsigned char *string;
- X{
- X register int i;
- X unsigned char *iptr, temp;
- X register char *optr;
- X
- X if (*string == '\0')
- X error("Null file name in MODEM7 batch receive", TRUE);
- X
- X for (iptr=string; (temp = *iptr) ; ) {
- X temp &= 0177; /* strips bit 7 */
- X if (isupper(temp))
- X temp |= 040; /* set bit 5 for lower case */
- X if (temp == '/')
- X temp=':'; /* map / into : */
- X *iptr++ = temp;
- X }
- X
- X /* put in main part of name */
- X iptr=string;
- X optr=filename;
- X for (i=0; i<8; i++) {
- X if (*iptr != ' ')
- X *optr++ = *iptr++;
- X }
- X
- X /* add dot if necessary */
- X if (string[8] != ' ' || string[9] != ' ' || string[10] != ' ')
- X *optr++ = '.';
- X
- X /* put in extension */
- X iptr = &string[8];
- X for (i=0; i<3; i++) {
- X if (*iptr != ' ')
- X *optr++ = *iptr++;
- X }
- X
- X *optr++ = '\000';
- X return (filename);
- X}
- X
- X/* Send 11 character CP/M filename for MODEM7 batch transmission
- X * Returns -1 for a protocol error; 0 if successful
- X * NOTE: we tromp a little on the argument string!
- X * code stolen from D. Thompson's (IRTF) xmodem.c
- X */
- X
- Xsend_name(name)
- Xchar *name;
- X{
- X register int cksum;
- X register char *ptr;
- X
- X xmdebug("send_name");
- X
- X /* append cp/m EOF */
- X name[NAMSIZ] = CTRLZ;
- X name[NAMSIZ+1] = '\000';
- X
- X /* create checksum */
- X ptr = name;
- X cksum = 0;
- X while (*ptr)
- X cksum += *ptr++;
- X cksum &= 0x00FF;
- X
- X /* send filename */
- X
- X sendbyte(ACK);
- X ptr = name;
- X sendbyte(*ptr++);
- X
- X while (*ptr) {
- X
- X switch (readbyte(15)) {
- X
- X case ACK: break;
- X
- X case TIMEOUT: {
- X logit("Timeout while sending MODEM7 filename\n");
- X tlogit("Timeout while sending MODEM7 filename\n");
- X sendbyte(BAD_NAME);
- X return (-1);
- X }
- X
- X default: {
- X logit("Error while sending MODEM7 filename\n");
- X tlogit("Error while sending MODEM7 filename\n");
- X sendbyte(BAD_NAME);
- X return (-1);
- X }
- X }
- X
- X sendbyte (*ptr++);
- X }
- X
- X /* Check checksum returned by other side against my value */
- X if (readbyte(16) != cksum) {
- X logit("Bad checksum while sending MODEM7 filename\n");
- X tlogit("Bad checksum while sending MODEM7 filename\n");
- X sendbyte(BAD_NAME);
- X return (-1);
- X }
- X
- X sendbyte(ACK);
- X return (0);
- X}
- X
- X/* Convert Unix filename to 11 character CP/M file name (8 char name,
- X * 3 char extension, dot in between is not included).
- X * map ':' into '/'; Use filename to hold name.
- X * code stolen from D. Thompson's (IRTF) xmodem.c
- X */
- X
- Xchar *
- Xunix_cpm(string)
- Xchar *string;
- X{
- X register char *iptr, *optr, temp;
- X int i;
- X
- X char *rindex();
- X char *strcpy();
- X
- X /* blank 11 character name */
- X (void) strcpy (filename," ");
- X
- X /* strip off any path name */
- X if ((iptr = rindex(string,'/')))
- X iptr++;
- X else
- X iptr=string;
- X
- X /* skip leading '.'s */
- X while (*iptr == '.')
- X iptr++;
- X
- X /* copy main part of name */
- X optr = filename;
- X i = 8;
- X while ((i--) && (*iptr) && (*iptr != '.'))
- X *optr++ = *iptr++;
- X
- X /* advance to unix extension, or end of unix name */
- X while ((*iptr != '.') && (*iptr))
- X iptr++;
- X
- X /* skip over the '.' */
- X while (*iptr == '.')
- X iptr++;
- X
- X /* copy extension */
- X optr = &filename[8];
- X i=3;
- X while ((i--) && (*iptr) && (*iptr != '.'))
- X *optr++ = *iptr++;
- X
- X filename[NAMSIZ] = '\000';
- X
- X /* Fuss with name */
- X for (iptr=filename; (temp = *iptr) ;) {
- X temp &= 0177; /* strip bit 7 (parity bit) */
- X if (islower(temp))
- X temp &= ~040; /* make upper case */
- X if (temp == ':')
- X temp ='/'; /* map ':' into '/' */
- X *iptr++ = temp;
- X }
- X
- X if (DEBUG)
- X fprintf (LOGFP, "DEBUG: File %s sent as %s\n", string, filename);
- X
- X return(filename);
- X}
- END_OF_FILE
- if test 4901 -ne `wc -c <'batch.c'`; then
- echo shar: \"'batch.c'\" unpacked with wrong size!
- fi
- # end of 'batch.c'
- fi
- if test -f 'misc.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'misc.c'\"
- else
- echo shar: Extracting \"'misc.c'\" \(4396 characters\)
- sed "s/^X//" >'misc.c' <<'END_OF_FILE'
- X#include "xmodem.h"
- X
- X/* Print Help Message */
- Xhelp()
- X {
- X fprintf(stderr, "Usage: \txmodem ");
- X fprintf(stderr, "-[rb!rt!ra!sb!st!sa][options] filename\n");
- X fprintf(stderr, "Major Commands --");
- X fprintf(stderr, "\n\trb <-- Receive Binary");
- X fprintf(stderr, "\n\trt <-- Receive Text");
- X fprintf(stderr, "\n\tra <-- Receive Apple macintosh text");
- X fprintf(stderr, "\n\tsb <-- Send Binary");
- X fprintf(stderr, "\n\tst <-- Send Text");
- X fprintf(stderr, "\n\tsa <-- Send Apple macintosh text");
- X fprintf(stderr, "\nOptions --");
- X fprintf(stderr, "\n\ty <-- Use YMODEM Batch Mode on transmit");
- X fprintf(stderr, "\n\tg <-- Select YMODEM-G Mode on receive");
- X fprintf(stderr, "\n\tm <-- Use MODEM7 Batch Mode on transmit");
- X fprintf(stderr, "\n\tk <-- Use 1K packets on transmit");
- X fprintf(stderr, "\n\tc <-- Select CRC mode on receive");
- X fprintf(stderr, "\n\tt <-- Indicate a TOO BUSY Unix system");
- X fprintf(stderr, "\n\td <-- Delete xmodem.log file before starting");
- X fprintf(stderr, "\n\tl <-- (ell) Turn OFF Log File Entries");
- X fprintf(stderr, "\n\tx <-- Include copious debugging information in log file");
- X fprintf(stderr, "\n\tp <-- Use with SunOS tip ~C command");
- X fprintf(stderr, "\n\tw <-- Wait before initial handshake");
- X fprintf(stderr, "\n\te <-- Supress EOT confirmation");
- X fprintf(stderr, "\n\tn <-- Allow mid-transfer CAN-CAN aborts");
- X fprintf(stderr, "\n");
- X }
- X
- X/* get type of transmission requested (text or binary) */
- Xgettype(ichar)
- Xchar ichar;
- X {
- X if (ichar == 't' || ichar == 'T')
- X return('t');
- X else if (ichar == 'b' || ichar == 'B')
- X return('b');
- X else if (ichar == 'a' || ichar == 'A')
- X return('a');
- X else
- X error("Invalid Send/Receive Parameter - not t or b", FALSE);
- X return('\0');
- X }
- X
- X/* return a string containing transmission type */
- Xchar *
- Xprtype(ichar)
- Xchar ichar;
- X {
- X if (ichar == 't' || ichar == 'T')
- X return("text");
- X else if (ichar == 'b' || ichar == 'B')
- X return("binary");
- X else if (ichar == 'a' || ichar == 'A')
- X return("apple");
- X else
- X return("");
- X }
- X
- X/* print error message and exit; if mode == TRUE, restore normal tty modes */
- Xerror(msg, mode)
- Xchar *msg;
- Xint mode;
- X {
- X if (mode)
- X restoremodes(TRUE); /* put back normal tty modes */
- X fprintf(stderr, "\r\n%s\n", msg);
- X if ((LOGFLAG || DEBUG) && (LOGFP != NULL))
- X {
- X fprintf(LOGFP, "XMODEM Fatal Error: %s\n", msg);
- X fclose(LOGFP);
- X }
- X exit(-1);
- X }
- X
- X
- X/* Construct a proper (i.e. pretty) sector count for messages */
- X
- Xchar
- X*sectdisp(recvsectcnt, bufsize, plus1)
- Xlong recvsectcnt;
- Xint bufsize, plus1;
- X {
- X static char string[20];
- X if (plus1)
- X recvsectcnt += (bufsize == 128) ? 1 : 8;
- X if (bufsize == 128 || recvsectcnt == 0)
- X sprintf (string, "%d", recvsectcnt);
- X else
- X sprintf (string, "%d-%d", recvsectcnt-7, recvsectcnt);
- X return(string);
- X }
- X
- X/* type out debugging info */
- Xxmdebug(str)
- Xchar *str;
- X {
- X if (DEBUG && (LOGFP != NULL))
- X fprintf(LOGFP,"DEBUG: '%s'\n",str);
- X }
- X
- X/* print elapsed time and rate of transfer in logfile */
- X
- Xint quant[] = { 60, 60, 24};
- Xchar sep[3][10] = { "second", "minute", "hour" };
- X
- Xprtime (numsect, seconds, fileid)
- Xlong numsect;
- Xtime_t seconds;
- XFILE *fileid;
- X
- X{
- X register int i;
- X register int Seconds;
- X int nums[3];
- X int rate;
- X
- X if (numsect == 0)
- X return(0);
- X
- X Seconds = (int)seconds;
- X Seconds = (Seconds > 0) ? Seconds : 0;
- X
- X rate = (Seconds != 0) ? 128 * numsect/Seconds : 0;
- X
- X for (i=0; i<3; i++) {
- X nums[i] = (Seconds % quant[i]);
- X Seconds /= quant[i];
- X }
- X
- X fprintf (fileid, "%ld Sectors Transfered in ", numsect);
- X
- X if (rate == 0)
- X fprintf (fileid, "0 seconds");
- X else
- X while (--i >= 0)
- X if (nums[i])
- X fprintf (fileid, "%d %s%c ", nums[i], &sep[i][0],
- X nums[i] == 1 ? ' ' : 's');
- X fprintf (fileid, "\n");
- X
- X if (rate != 0)
- X fprintf (fileid, "Transfer Rate = %d Characters per Second\n", rate);
- X
- X return(0);
- X}
- X
- X/* Print elapsed time estimate */
- X
- Xprojtime (numsect, fd)
- Xlong numsect;
- XFILE *fd;
- X {
- X register int i;
- X register int seconds;
- X int nums[3];
- X
- X if (numsect == 0)
- X return (0);
- X
- X/* constant below should really be 1280; reduced to 90% to account for time lost in overhead */
- X
- X seconds = 1422 * numsect / ttyspeed + 1;
- X
- X for (i=0; i<3; i++) {
- X nums[i] = (seconds % quant[i]);
- X seconds /= quant[i];
- X }
- X
- X fprintf (fd, "Estimated transmission time ");
- X
- X while (--i >= 0)
- X if (nums[i])
- X fprintf (fd, "%d %s%c ", nums[i], &sep[i][0],
- X nums[i] == 1 ? ' ' : 's');
- X fprintf (fd, "\n");
- X return (0);
- X }
- END_OF_FILE
- if test 4396 -ne `wc -c <'misc.c'`; then
- echo shar: \"'misc.c'\" unpacked with wrong size!
- fi
- # end of 'misc.c'
- fi
- if test -f 'xmodem.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'xmodem.1'\"
- else
- echo shar: Extracting \"'xmodem.1'\" \(10889 characters\)
- sed "s/^X//" >'xmodem.1' <<'END_OF_FILE'
- X.TH XMODEM LOCAL "November 2, 1990"
- X.UC 4.2
- X.SH NAME
- Xxmodem \- Christensen protocol file transfer utility \- Version 3.9, November 1990
- X.SH SYNOPSIS
- X.B xmodem
- X[\fBst|sb|sa|rt|rb|ra\fR][\fBygmkctdlxpwen\fR]
- X[file...]
- X.br
- X.SH DESCRIPTION
- XThe
- X.I xmodem
- Xprogram implements the Christensen (XMODEM) file transfer
- Xprotocol for moving files between 4.2/4.3BSD Unix systems (and successors,
- Xincluding Suns) and microcomputers.
- XThe XMODEM/CRC protocol, the MODEM7 batch protocol, the XMODEM-1K
- Xblock protocol, the YMODEM batch protocol and the YMODEM-G streaming protocol
- Xare all supported by
- X.IR xmodem .
- XThe ZMODEM protocol is not supported.
- XFor details of the XMODEM/YMODEM protocols,
- Xsee the document edited by Chuck Forsberg titled
- X.I
- XXMODEM/YMODEM Protocol Reference.
- X.sp
- XOption Flags are case insensitive; the cluster of flags
- Xmay be preceded by an optional "-"
- Xcharacter.
- X.PP
- X.SH PARAMETERS
- XExactly one of the following must be selected:
- X.TP
- X.B rb
- XReceive Binary - files are placed on the Unix disk without conversion.
- X.I Xmodem
- Xwill silently destroy existing files of the same name.
- X.TP
- X.B rt
- XReceive Text - files are converted from the CP/M and MS-DOS
- Xformat of CR-LF pairs to the Unix convention of newline
- Xcharacters only between lines.
- XNull bytes are ignored and bit 8 of each character is stripped (which makes
- XWordstar files much more readable).
- XA CTRL-Z character is deemed to indicate the EOF location in the incoming
- Xfile.
- XThe resulting file
- Xis acceptable to the Unix editors and compilers, and is usually slightly
- Xsmaller than the original file.
- X.I Xmodem
- Xwill silently destroy existing files of the same name.
- X.TP
- X.B ra
- XReceive Apple - same as rt save CR characters in the incoming file are
- Xtranslated into Unix newline characters.
- X.TP
- X.B sb
- XSend Binary - files are sent without conversion as they exist on the Unix disk.
- X.TP
- X.B st
- XSend Text - newline characters in the file are converted to CR-LF pairs
- Xin accord with the CP/M and MS-DOS conventions for text files. The file
- X"grows" in this process.
- X.TP
- X.B sa
- XSend Apple - same as st save newline characters are converted into CR
- Xcharacters in accord with Apple Macintosh conventions for text files.
- X.PP
- X.SH OPTIONS
- X.TP
- X.B y
- XSelect the YMODEM batch protocol for sending files; a list of files specified
- Xon the command line will be sent in sequence. The YMODEM batch protocol is
- Xused automatically for file reception if the sending program requests it.
- XIf this flag is specified for a batch receive, (\fIxmodem rty\fR, for example),
- Xthe transfer will never attempt to switch from CRC to checksum mode.
- X.TP
- X.B g
- XSelect the YMODEM-G variant of YMODEM when receiving files. YMODEM-G is
- Xautomatically invoked on transmit if the receiving program requests it.
- XYMODEM-G is designed for "error-free" connections with proper flow control;
- Xthe transmitting program blasts packets to the receiver as fast as it can
- Xwithout waiting for acknowledgements. Any errors cause the entire file
- Xtransfer to be aborted.
- X.TP
- X.B m
- XSelect the MODEM7 batch protocol for sending files; a list of files specified
- Xon the command line will be sent in sequence. The MODEM7 batch protocol is
- Xused automatically for file reception if the sending program requests it.
- XIf this flag is specified for a batch receive, (\fIxmodem rbm\fR, for example),
- Xthe transfer starts in checksum mode rather than CRC mode. If both "m" and
- X"c" are specified on a receive command, the initial "file-name" negotiations
- Xare done using checksums while the file transfers are done using CRC-16.
- X.TP
- X.B k
- XSelect the XMODEM-1K file transfer mode for sending files. Use of 1K packets on
- Xlow-error lines increases throughput.
- XHowever, over direct connections at 9600 bps to a busy host, 1K packets may
- Xcause data overflows generating excessive retries.
- X1K packets are automatically
- Xused for file reception if the sending program requests it.
- XIf this flag is specified with the YMODEM flag in a batch receive (\fIxmodem
- Xrbyk\fR, for example), the program will attempt to use the "KMD/IMP" convention
- Xto invoke 1K file transfers.
- X.TP
- X.B c
- XSelect the CRC-16 error-checking protocol on receive. CRC mode is better at catching
- Xtransmission errors that occur than the alternative checksum protocol.
- XCRC mode is automatically selected for file
- Xtransmission if the receiving modem program requests it.
- X.TP
- X.B t
- XIndicates the Unix system is Too Busy and
- X.I xmodem
- Xshould fall back to a simpler I/O strategy than normal.
- X.TP
- X.B d
- XDelete the
- X.I xmodem.log
- Xfile before file transfer is begun.
- X.TP
- X.B l
- XDo NOT write to the log file. If logging is selected, a file
- X.I xmodem.log
- Xwill be created (or appended to), with entries for significant events, errors
- Xand retries. This can be useful to see why things went wrong
- Xwhen they do.
- X.TP
- X.B x
- XToggle on debug mode. If debug mode is selected, copious and possibly
- Xuseful debugging information will be placed in
- X.IR xmodem.log .
- X.TP
- X.B p
- XAssume that
- X.I xmodem
- Xis being invoked through SunOS tip (via the ~C command). Status and error
- Xmessages will be sent to stderr, and hence to your screen, while the transfer
- Xis in progress.
- X.B Do
- X.B not
- Xuse this option unless you are using tip!
- X.TP
- X.B w
- XWait 15 seconds before initiating the startup handshake. Useful if handshake
- Xcharacters are trashing things you need to type.
- X.TP
- X.B e
- XSuppress EOT verification.
- XNormally,
- X.I xmodem
- Xtries to verify an EOT character (used to signify the end of file) by
- XNAKing it and waiting for the EOT to be resent. This reliability feature
- Xcan generate harmless error messages in some microcomputer file transfer
- Xprograms; other programs refuse to work at all. To accomodate the latter
- Xbrain-damaged programs, use the "e" option.
- X.TP
- X.B n
- XAllow CAN-CAN aborts during mid-transfer. Normally, as a reliability feature,
- XCAN-CAN aborts are only allowed at the beginning of a file transfer. If you
- Xdon't like this feature, use the "n" flag.
- X.SH "FILE NAMES"
- XFiles transmitted using one of the batch modes
- Xwill be stored on the remote machine under a CP/M-ified name (path names
- Xstripped, limited
- Xto eight characters plus a three character extension; ":" characters will
- Xbe turned into "/" characters; all characters will be in monocase).
- XFiles received using one of the batch modes
- Xwill be stored under their transmitted names (except that any "/" characters
- Xin the file name will be converted into ":" characters, all upper-case
- Xcharacters will be translated into lower case and trailing dots will be
- Xexpunged).
- X.PP
- XWhen a batch receive is requested,
- X.I xmodem
- Xtakes a wait and see attitude and can adapt to either batch protocol or even
- Xa classic XMODEM transfer (note that CRC-16 mode is automatically set under
- Xthese circumstances unless the b flag is specified).
- XIf a classic, "non-batch" XMODEM file reception takes place,
- Xthe received file is stored as
- X.IR xmodem.in .
- XFile names present on the command line for a batch receive are ignored.
- X.SH NOTES
- XRemember, CRC-16 error detection and YMODEM-G streaming must be invoked by
- Xthe
- X.B receiving
- Xprogram while 1K blocksize must be invoked by the
- X.B sending
- Xprogram.
- X.PP
- XWhile waiting for the beginning of a file transfer,
- X.I xmodem
- Xtreats two CAN (CTRL-X) characters that are received within 3 seconds
- Xas a request to abort. CAN characters will not cause an abort if received
- Xin the midst of a file transfer (unless the "n" option was invoked).
- X.PP
- XIf 10 or more errors are detected during the transmission or reception of any
- Xone packet, the transfer is aborted.
- X.PP
- XSqueezed, compressed, ZIPed or ARCed files must be transferred in binary mode,
- Xeven if they contain text.
- X.PP
- XIf you use
- X.I xmodem
- Xover a
- X.I rlogin
- Xlink, you may have to use the form
- X.IR "rlogin machine -8" .
- X.PP
- XIf an unexpected error occurs before a file is completely received, the
- Xincomplete file is deleted.
- X.PP
- XFiles received using both binary and text mode in a YMODEM batch transfer
- Xwill be truncated
- Xto the file size specified in the YMODEM header (extra CR characters in the
- Xincoming file are correctly handled). File sizes are included in
- Xthe YMODEM header when sending both binary and text files. Thus files
- Xtransferred via YMODEM should preserve their exact length.
- XFile modification times are set for received files if present in the YMODEM
- Xheader; they are included in the headers for transmitted files (watch for
- Xtimezone problems, however).
- X.PP
- XThe "KMD/IMP" record count field in the YMODEM header is both set and read.
- X.PP
- X.I xmodem
- Xcan be used through the SunOS
- X.I tip
- Xprogram to transfer files. Use
- X.I tip
- Xto establish a session on a remote computer. Enter the file transfer
- Xcommand on the remote computer to send or receive files, then use the ~C
- Xcommand which causes
- X.I tip
- Xto request a local command string and enter the appropriate
- X.I xmodem
- Xcommand. Use the "p" option on the local
- X.I xmodem
- Xcommand so you will see status reports on your screen.
- XIf the
- X.I xmodem
- Xis running on the remote machine, use the "w" option there to halt the
- Xinitiation of file-transfer handshaking for a bit to allow you to enter the ~C
- Xcommand line without interference.
- X.PP
- XThe MODEM7 batch protocol is archaic and should only be used if YMODEM batch
- Xprotocols are not available in your PC's communication program. If you must
- Xuse MODEM7, you may have to specify the "m" option or, preferably, "cm"
- Xwhen receiving files with
- X.IR xmodem .
- X.SH EXAMPLES
- X.PP
- XTo receive a text file transmitted from a micro (using CRC-16
- Xerror-checking) and store it under the
- Xname
- X.IR file.name ,
- Xuse the command line
- X.RS
- X.B "xmodem rtc file.name"
- X.RE
- XNote that if the transmitting program on the micro uses the 1K packet
- Xprotocol and/or the YMODEM batch protocol,
- X.I xmodem
- Xdetects this automatically and takes appropriate action. Further
- Xnote that if one of the batch protocols is used, the received file(s)
- Xwill be stored under their own names and the name on the command line
- X(if any) will be ignored. Finally, note that CRC-16 error checking is the
- Xdefault. Thus, a generic command to receive files would be
- X.RS
- X.B "xmodem rt"
- X.RE
- X.PP
- XTo send a set of text files to a microcomputer using 1K packets and the
- XYMODEM batch protocol, use the command line
- X.RS
- X.B "xmodem styk *.txt"
- X.RE
- X.SH FILES
- Xxmodem.log (if logging is enabled)
- X.SH BUGS
- XBatch mode could be smarter about bad file-names in the midst of a
- Xbatch transmit/receive.
- X.PP
- XBatch mode could allow a mixture of binary and text files.
- X.PP
- XBare Carriage Return characters (i.e., those not immediately followed by a
- XLine Feed character) are mishandled in a received file when using text mode.
- XA file with "overstruck" lines will thus come out looking funny.
- X.SH SEE ALSO
- Xkermit(1), rz(1), sz(1)
- X.SH AUTHOR
- XSteve Grandi, National Optical Astronomy Observatories (grandi@noao.edu).
- XBased on
- X.I xmodem
- Xby Brian Kantor, University of California at San Diego.
- XThis, in turn, was based on
- X.I umodem
- Xby Lauren Weinstein, Richard Conn and others.
- END_OF_FILE
- if test 10889 -ne `wc -c <'xmodem.1'`; then
- echo shar: \"'xmodem.1'\" unpacked with wrong size!
- fi
- # end of 'xmodem.1'
- fi
- if test -f 'xmodem.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'xmodem.h'\"
- else
- echo shar: Extracting \"'xmodem.h'\" \(3839 characters\)
- sed "s/^X//" >'xmodem.h' <<'END_OF_FILE'
- X#include <ctype.h>
- X#include <stdio.h>
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X#include <sys/time.h>
- X#include <sgtty.h>
- X#include <signal.h>
- X
- X/* define macros to print messages in log file */
- X#define logit(string) if(LOGFLAG)fprintf(LOGFP,string)
- X#define logitarg(string,argument) if(LOGFLAG)fprintf(LOGFP,string,argument)
- X#define tlogit(string) if(TIPFLAG)fprintf(stderr,string)
- X#define tlogitarg(string,argument) if(TIPFLAG)fprintf(stderr,string,argument)
- X
- X#define VERSION "3.9 (November 1990)"
- X#define FALSE 0
- X#define TRUE 1
- X
- X
- X/* ASCII Constants */
- X#define SOH 001
- X#define STX 002
- X#define ETX 003
- X#define EOT 004
- X#define ENQ 005
- X#define ACK 006
- X#define LF 012 /* Unix LF/NL */
- X#define CR 015
- X#define NAK 025
- X#define SYN 026
- X#define CAN 030
- X#define ESC 033
- X
- X/* XMODEM Constants */
- X#define TIMEOUT -1
- X#define ERRORMAX 10 /* maximum errors tolerated while transferring a packet */
- X#define WAITFIRST 1 /* seconds between startup characters in read */
- X#define STERRORMAX 60 /* maximum "errors" tolerated in read startup */
- X#define CRCSWMAX 30 /* maximum time to try CRC mode before switching */
- X#define NAKMAX 120 /* maximum times to wait for initial NAK when sending */
- X#define RETRYMAX 5 /* maximum retries to be made certain handshaking routines */
- X#define KSWMAX 5 /* maximum errors before switching to 128 byte packets */
- X#define EOTMAX 10 /* maximum times sender will send an EOT to end transfer */
- X#define SLEEPNUM 100 /* target number of characters to collect during sleepy time */
- X#define BBUFSIZ 1024 /* buffer size */
- X#define NAMSIZ 11 /* length of a CP/M file name string */
- X#define CTRLZ 032 /* CP/M EOF for text (usually!) */
- X#define CRCCHR 'C' /* CRC request character */
- X#define KCHR 'K' /* 1K block request character */
- X#define GCHR 'G' /* Ymodem-G request character */
- X#define BAD_NAME 'u' /* Bad filename indicator */
- X#define TIPDELAY 15 /* seconds to delay handshake startup when -w */
- X
- X#define CREATMODE 0644 /* mode for created files */
- X
- X/* GLOBAL VARIABLES */
- X
- Xint ttyspeed; /* tty speed (bits per second) */
- Xunsigned char buff[BBUFSIZ]; /* buffer for data */
- Xint nbchr; /* number of chars read so far for buffered read */
- Xlong filelength; /* length specified in YMODEM header */
- Xlong fileread; /* characters actually read so far in file */
- Xchar filename[256]; /* place to construct filenames */
- Xint yfilesleft; /* # of files left for YMODEM header */
- Xlong ytotleft; /* # of bytes left for YMODEM header */
- X
- XFILE *LOGFP; /* descriptor for LOG file */
- X
- X/* option flags and state variables */
- Xchar XMITTYPE; /* text or binary? */
- Xint DEBUG; /* keep debugging info in log? */
- Xint RECVFLAG; /* receive? */
- Xint SENDFLAG; /* send? */
- Xint BATCH; /* batch? (Now used as a state variable) */
- Xint CRCMODE; /* CRC or checksums? */
- Xint DELFLAG; /* don't delete old log file? */
- Xint LOGFLAG; /* keep log? */
- Xint LONGPACK; /* do not use long packets on transmit? */
- Xint MDM7BAT; /* MODEM7 batch protocol */
- Xint YMDMBAT; /* YMODEM batch protocol */
- Xint TOOBUSY; /* turn off sleeping in packet read routine */
- Xint TIPFLAG; /* for tip ~C command */
- Xint DELAYFLAG; /* for startup delay */
- Xint NOEOT; /* suppress EOT verification */
- Xint CANCAN; /* allow CAN-CAN aborts anytime */
- Xint YMODEMG; /* YMODEM-G variant of YMODEM */
- X
- Xint CHECKLENGTH; /* Are we truncating a file to a YMODEM length? */
- X
- X
- X/* CRC-16 constants. From Usenet contribution by Mark G. Mendel,
- X Network Systems Corp. (ihnp4!umn-cs!hyper!mark)
- X*/
- X
- X /* the CRC polynomial. */
- X#define P 0x1021
- X
- X /* number of bits in CRC */
- X#define W 16
- X
- X /* the number of bits per char */
- X#define B 8
- END_OF_FILE
- if test 3839 -ne `wc -c <'xmodem.h'`; then
- echo shar: \"'xmodem.h'\" unpacked with wrong size!
- fi
- # end of 'xmodem.h'
- fi
- echo shar: End of archive 3 \(of 3\).
- cp /dev/null ark3isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-